#include "basebtnwidget.h"
#include "commondef.h"
#include <QMouseEvent>
#include "global/myresource.h"
#include "global/globalvar.h"
#include <QDebug>

BaseBtnWidget::BaseBtnWidget(QWidget *parent) :
    QWidget             (parent),
    m_state             (NORMAL_IB)
{
}

void BaseBtnWidget::mousePressEvent(QMouseEvent *e)
{
    m_state = PRESS_IB;
    if(globalvar::m_bVoice)
    {
        MyResource::play(1);
    }
    update();
}

void BaseBtnWidget::mouseReleaseEvent(QMouseEvent *e)
{
    if(m_state != NORMAL_IB)
    {
        m_state = NORMAL_IB;
        update();

        emit myclick();
    }
}

void BaseBtnWidget::mouseMoveEvent(QMouseEvent *e)
{
    qDebug()<<m_size;
    if(QRectF(QPointF(0.0f,0.0f),m_size).contains(e->pos()))
    {
        m_state = PRESS_IB;
    }
    else
    {
        m_state = NORMAL_IB;
    }

    update();
}
